class CreateProductos < ActiveRecord::Migration
  def change
    create_table :productos do |t|
    	t.column :nombre, :string, :limit => 255, :null => false
    	t.column :descripcion, :string, :limit => 255, :null => false
    	t.column :tipo, :string, :limit => 255, :null => false
	t.column :productor_id, :integer, :null => false
    	t.column :precio, :float, :null => false
      	t.timestamps
    end
    def up
        say_with_time 'Adding foreing keys' do
            # Add foreign key reference to productors table
            execute 'ALTER TABLE productos ADD CONSTRAINT fk_productos_productors
              FOREIGN KEY ( productor_id ) REFERENCES productors( id ) ON DELETE CASCADE'
    end
    end
  end
end
